__author__ = 'galushkoss'
_author__ = 'MyHome'
#from django.utils import simplejson
import json
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register

from bpk.models import Category, Materials
from django.template import RequestContext
from django.template.loader import render_to_string


@dajaxice_register
def fill_table(request, mt):
	dajax = Dajax()
	Docs=Materials.objects.filter(section__title=mt)
	html=render_to_string("docstable.html",{'Docs':Docs})
	dajax.assign('#ajax-table','innerHTML',html)
	return dajax.json()


@dajaxice_register
def all_data(request):
	dajax = Dajax()
	Docs=Materials.objects.order_by("title")
	html=render_to_string("docstable.html",{'Docs':Docs})
	dajax.assign('#ajax-table','innerHTML',html)
	return dajax.json()
